#include <iostream>
#include <stdio.h>

#define SIZE 50

int main()
{
	double numbers[SIZE], minimum, maximum, number, temp;
	int i, p1, p2, n;
	
	std::cout << "n = ";
	std::cin >> n;
	std::cout << "number[0] = ";	
	std::cin >> numbers[0];
	number = numbers[0];
	minimum = number;
	maximum = number;
	for (i = 1; i < n; ++i)
	{
		std::cout << "number[" << i << "] = ";
		std::cin >> numbers[i];
	}	
	
	for (i = 1; i < n; ++i)
	{
		if (numbers[i] > maximum)
			maximum = numbers[i];
		if (numbers[i] < minimum)
			minimum = numbers[i];
	}

	for (i = 0; i < n; ++i)
	{	
		if(numbers[i] == minimum)
			p1 = i;
		if(numbers[i] == maximum)
			p2 = i;
	}
	temp = numbers[p1];
	numbers[p1] = numbers[p2];
	numbers[p2] = temp;

	for (i = 0; i < n; ++i)
		std::cout << numbers[i];
	
	return 0;
}
